version: "3"

services:
  mongo:
    image: "mongo"
    container_name: "mongo"
    restart: "always"
    environment:
      MONGO_INITDB_ROOT_USERNAME: "{{ combined_vars.mongo.root_name }}"
      MONGO_INITDB_ROOT_PASSWORD: "{{ combined_vars.mongo.root_pass }}"
    volumes:
      - "{{ combined_vars.mongo.data_path }}:/data/db"
      - "/usr/share/zoneinfo/{{ global_timezone }}:/etc/localtime"
    ports:
      - "{{ combined_vars.mongo_port }}:27017"

{% if mongo_express_enabled %}
  mongo-express:
    image: "mongo-express"
    container_name: "mongo-express"
    restart: "always"
    environment:
      ME_CONFIG_BASICAUTH_USERNAME: "{{ combined_vars.mongo_express.username }}"
      ME_CONFIG_BASICAUTH_PASSWORD: "{{ combined_vars.mongo_express.password }}"
      ME_CONFIG_MONGODB_URL: "mongodb://{{ combined_vars.mongo.root_name }}:{{ combined_vars.mongo.root_pass | quote }}@{{ global_bond_ip }}:{{ combined_vars.mongo_port }}/"
    volumes:
      - "/usr/share/zoneinfo/{{ global_timezone }}:/etc/localtime"
    ports:
      - "{{ combined_vars.mongo_express_port }}:8081"
    depends_on:
      - mongo
{% endif %}